package psd.views;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.ICompilationUnit;

import psd.core.CompilationUnitManager;
import psd.model.Bug;


public class MarkerPrinter extends BugPrinter{

	@Override
	public void Print(Bug bug) {
		try {
			IResource resource =  ((ICompilationUnit)CompilationUnitManager.Instance().get_CompilationUnit(bug.get_path())).getCorrespondingResource(); 
			IMarker marker = resource.createMarker("psd.codeProblems");
			marker.setAttribute(IMarker.LOCATION,  "Line " +  bug.get_lineNumber());
			marker.setAttribute(IMarker.MESSAGE, bug.get_description());
			marker.setAttribute(IMarker.LINE_NUMBER, bug.get_lineNumber());
			marker.setAttribute(IMarker.PRIORITY, bug.get_priority());
			
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
